package com.wee.aircoach_user;

import android.content.Context;
import android.util.Log;

/**
 * Created by Solomon on 2015/10/26.
 */
public class Common {


    /**
     * 获取软件版本号
     *
     * @param context
     * @return
     */
    public static int getVerCode(Context context) {
        int verCode = -1;
        try {
            //注意："com.wee.aircoach_user"对应AndroidManifest.xml里的package="……"部分
            verCode = context.getPackageManager().getPackageInfo(
                    "com.wee.aircoach_user", 0).versionCode;
        } catch (Exception e) {
            Log.e("msg", e.getMessage());
        }
        return verCode;
    }

    /**
     * 获取版本名称
     *
     * @param context
     * @return
     */
    public static String getVerName(Context context) {
        String verName = "";
        try {
            verName = context.getPackageManager().getPackageInfo(
                    "", 0).versionName;
        } catch (Exception e) {
            Log.e("msg", e.getMessage());
        }
        return verName;
    }

}